package com.example.shopdemo.controller.dashboard;

import com.example.shopdemo.entity.Product;
import com.example.shopdemo.service.ProductServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ：Anitaxiaofeng
 * @description：
 * @create 2018-01-27
 **/
@Controller
@RequestMapping("/dashboard")
public class ProductDetailController {


    @Autowired
    private ProductServiceImpl productService;

    @RequestMapping("/listProductDetailPageInfo")
    @ResponseBody
    public Map<String,Object> listProductDetailPageInfo(@RequestParam("productId")Long productId){
        Map<String,Object> modelMap = new HashMap<>();
        Product  product = productService.getProductById(productId);
        if(product!=null){
            modelMap.put("product",product);
            modelMap.put("success",true);
        }else{
            modelMap.put("success",false);
            modelMap.put("errMsg","product is null");
        }
        return modelMap;
    }

}
